package com.cheer.dao;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cheer.entity.OaArticleClassEntity;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 文章分类
 * 
 * @author cheer
 */
@Mapper
@Repository
public interface OaArticleClassDao extends BaseMapper<OaArticleClassEntity> {

    default IPage<OaArticleClassEntity> selectPage(Integer pageNum, Integer pageSize) {
        return selectPage(new Page<>(pageNum, pageSize), Wrappers.emptyWrapper());
    }

    default List<OaArticleClassEntity> selectListByLocation(Integer type) {
        return selectList(new QueryWrapper<OaArticleClassEntity>()
                .eq("location", type)
                .eq("status", true));
    }

    default OaArticleClassEntity selectByIdAndStatus(Integer id, Boolean status) {
        return selectOne(new QueryWrapper<OaArticleClassEntity>()
            .eq("id", id)
            .eq("status", true));
    }
}
